all:
	@cmake -S . -B cmake_build && cmake --build cmake_build

nj:
	@cmake -S . -B cmake_build -G Ninja && cmake --build cmake_build

mf:
	@cmake -S . -B cmake_build -G "Unix Makefiles" && cmake --build cmake_build

help:
	@echo -e "Available targets: \n\
	all   -- default project\n\
	nj    -- ninja project\n\
	mf    -- makefile project\n\
	run   -- run the program\n\
	clean -- clean the project\n\
	rm    -- clean the project and remove cmake_build dir"

.PHONY: run
run: 
	@cmake --build cmake_build --target run
# or `./cmake_build/src/main`/`./cmake_build/src/[Debug|Release]/main`
#
# 关于程序运行时的工作目录(pwd):
# `cmake --build cmake_build --target run`的工作目录是在可执行文件的目录
# `./cmake_build/src/main`的工作目录是工程的根目录，代码中的相对路径需要注意
# windows需要把dll文件拷到PATH或者当前路径下，两种方法要拷贝到的路径不同

.PHONY: clean
clean:
	@cmake --build cmake_build --target clean

.PHONY: rm
rm:
	@rm -rf cmake_build
